package com.zlt.bkparking.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Classname TimeUtil
 * @Description TODO
 * @Date 2022/10/3 23:01
 * @Created by ${Lijijun}
 */
public class TimeUtil {
    //判断日期是否过期
    public static boolean isNotExpired(Date endTime) throws ParseException {
        Date currentTime = new Date();
        int i = endTime.compareTo(currentTime);//截止时间与当前时间作比较   返回的值 小于等于0 就过期了
        boolean bool = true;
        if (i<=0){
            bool = false;//过期
        }
        return bool;
    }

    public static String getCurrentDateString(){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        String format = sdf.format(date);
        return format;
    }

    public static Date incrementDate(){
        Date dt = new Date();
        Calendar rightNow = Calendar.getInstance();
        rightNow.setTime(dt);//设置日期
        rightNow.add(Calendar.DAY_OF_MONTH,1);
        Date dt1=rightNow.getTime();
        return dt1;
    }


}
